package com.zhengqing.design.action.visitor._01.computer.impl;

import com.zhengqing.design.action.visitor._01.ComputerPartVisitor;
import com.zhengqing.design.action.visitor._01.computer.ComputerPart;

public class Computer implements ComputerPart {

    ComputerPart[] parts;

    public Computer() {
        this.parts = new ComputerPart[]{new Mouse(), new Keyboard()};
    }

    @Override
    public void accept(ComputerPartVisitor computerPartVisitor) {
        for (int i = 0; i < this.parts.length; i++) {
            this.parts[i].accept(computerPartVisitor);
        }
        computerPartVisitor.visit(this);
    }
}
